package com.kaifamiao.format;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;

public class DateTimeFormatterTest2 {

    public static void main(String[] args) {

        String source = "2022-08-12T16:30:01.456220600";

        String pattern = "yyyy-MM-dd'T'HH:mm:ss.n";
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern( pattern );

        // 根据符合特定模式的字符串解析后的结果创建一个 TemporalAccessor实例
        TemporalAccessor ta = dtf.parse( source );
        System.out.println( ta );

        // TemporalAccessor ------>  LocalDateTime
        LocalDateTime dt = LocalDateTime.from( ta );
        System.out.println( dt );

    }

}
